home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / gnuplot1.10A / part03 < prev    next >
Encoding:
Text File  |  1989-09-09  |  48.5 KB  |  2,431 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v08i037: GnuPlot v1.10A (part 3 of 7)
  4. Reply-To: canoaf@ntvax.UUCP (Augustine Cano)
  5.  
  6. Posting-number: Volume 8, Issue 37
  7. Submitted-by: canoaf@ntvax.UUCP (Augustine Cano)
  8. Archive-name: gnuplot1.10A/part03
  9.  
  10. [OOPS!!!  I had to patch these after receiving them -- and managed to lose the
  11. name of the person who submitted them in the process.  Duh.  The name shown
  12. is a "best guess".  Submitter, please correct me.  ++bsa]
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 3 (of 7)."
  21. # Contents:  make.msc makefile.3b1 makefile.tc makefile.unx misc.c
  22. #   parse.c pc.trm pcgraph.asm
  23. # Wrapped by allbery@uunet on Sat Sep  9 13:47:21 1989
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'make.msc' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'make.msc'\"
  27. else
  28. echo shar: Extracting \"'make.msc'\" \(1136 characters\)
  29. sed "s/^X//" >'make.msc' <<'END_OF_FILE'
  30. XOBJS =     command.obj eval.obj graphics.obj internal.obj misc.obj parse.obj plot.obj scanner.obj standard.obj term.obj util.obj version.obj pcgraph.asm corgraph.asm hrcgraph.asm
  31. X
  32. X# /AC means use compact model (small code, large data)
  33. XCFLAGS = /AC /DPC #/Zi #/Od
  34. X
  35. XTERMFLAGS = /DHERCULES /DATT6300 /DCORONA /DPOSTSCRIPT /DHP75 /DTEK /DV384 /DEGALIB
  36. X
  37. XLINKFLAGS = #/codeview
  38. X
  39. X# default rules
  40. X.c.obj:
  41. X    msc $(CFLAGS) $*;
  42. X
  43. X.asm.obj:
  44. X    masm $*;
  45. X
  46. Xpcgraph.obj: pcgraph.asm header.mac lineproc.mac
  47. X
  48. Xcorgraph.obj: corgraph.asm header.mac lineproc.mac
  49. X
  50. Xhrcgraph.obj: hrcgraph.asm header.mac lineproc.mac
  51. X
  52. Xcommand.obj: command.c plot.h
  53. X
  54. Xeval.obj: eval.c plot.h
  55. X
  56. Xgraphics.obj: graphics.c plot.h
  57. X
  58. Xinternal.obj: internal.c plot.h
  59. X
  60. Xmisc.obj: misc.c plot.h
  61. X
  62. Xparse.obj: parse.c plot.h
  63. X
  64. Xplot.obj: plot.c plot.h
  65. X
  66. Xscanner.obj: scanner.c plot.h
  67. X
  68. Xstandard.obj: standard.c plot.h
  69. X
  70. Xterm.obj: term.c plot.h
  71. X    msc $(CFLAGS) $(TERMFLAGS) term;
  72. X
  73. Xutil.obj: util.c plot.h
  74. X
  75. Xversion.obj: version.c
  76. X
  77. X
  78. X# use link.opt to avoid command-line overflow
  79. X
  80. Xgnuplot.exe: $(OBJS)
  81. X link$(LINKFLAGS) @link.opt
  82. X exepack gnuplot.exe gnupack.exe
  83. X del gnuplot.exe
  84. X ren gnupack.exe gnuplot.exe
  85. END_OF_FILE
  86. if test 1136 -ne `wc -c <'make.msc'`; then
  87.     echo shar: \"'make.msc'\" unpacked with wrong size!
  88. fi
  89. # end of 'make.msc'
  90. fi
  91. if test -f 'makefile.3b1' -a "${1}" != "-c" ; then 
  92.   echo shar: Will not clobber existing file \"'makefile.3b1'\"
  93. else
  94. echo shar: Extracting \"'makefile.3b1'\" \(3933 characters\)
  95. sed "s/^X//" >'makefile.3b1' <<'END_OF_FILE'
  96. X# "make all" will compile all the necessary programs, gnuplot itself, the
  97. X# help system and helptree (to make the help tree out of the flat file.)
  98. X#
  99. X# "make install will install all the necessary pieces to run gnuplot
  100. X# successfully.  This includes creating the help tree in /usr/local/help.
  101. X
  102. X# If you do not wish the destinations of the executable and manual page to
  103. X# be at the default locations (see below), feel free to change them.
  104. X# The location of the help system and help tree also have default values.
  105. X# If you want them somewhere else or would like to test the whole system
  106. X# before you run "make install", you have to set environment variables so
  107. X# that gnuplot finds them.  See README.3B1 for details.
  108. X
  109. X# where to install executable on 'make install'
  110. XDEST=/usr/local/bin/gnuplot
  111. X# where to install man page on 'make man_install'
  112. XMANDEST=/usr/man/man1/gnuplot.1
  113. X
  114. X# -DFORK if you have vfork()
  115. X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
  116. X# -DNOCOPY if you don't have a memcpy() by any name
  117. X# -DGAMMA if you've got gamma(3)
  118. X# -O if you trust your compiler's optimizer
  119. XCFLAGS = -DGAMMA -DUNIXPC -O # -gx # debug it.
  120. X
  121. X# -D<terminal> in TERMFLAGS iff you wish to support <terminal>
  122. X# -DAED         AED 512 and AED 767
  123. X# -DBITGRAPH    BBN BitGraph
  124. X# -DHP26        HP2623A and maybe others
  125. X# -DHP75        HP7580, and probably other HPs
  126. X# -DHPLJET      HP LaserJet laserprinter
  127. X# -DPOSTSCRIPT  Postscript
  128. X# -DQMS         QMS/QUIC laserprinter (Talaris 1200 and others)
  129. X# -DREGIS       ReGis graphics (vt125, vt220, vt240, Gigis...)
  130. X# -DSELANAR     Selanar
  131. X# -DTEK         Tektronix 4010, and probably others
  132. X# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
  133. X# -DUNIXPLOT    unixplot
  134. X# -DV384        Vectrix 384 and tandy color printer
  135. X
  136. XTERMFLAGS = -DUNIXPC -DUNIXPLOT
  137. X
  138. X
  139. XOBJS =     command.o eval.o graphics.o internal.o misc.o parse.o plot.o scanner.o\
  140. X    standard.o term.o util.o
  141. X
  142. X# -lplot if you have -DUNIXPLOT
  143. XLIBS = -lm -lplot
  144. X
  145. X# If you do not wish to compile the help system or make the help directory
  146. X# tree, feel free to comment out the appropriate lines that do it.
  147. X
  148. Xall:    gnuplot help_system doc_tree
  149. X
  150. Xgnuplot: $(OBJS) version.o
  151. X    ld /lib/crt0s.o /lib/shlib.ifile $(OBJS) version.o $(LIBS) -o gnuplot
  152. X
  153. Xhelp_system:
  154. X    ( cd help ; make )
  155. X
  156. Xdoc_tree:
  157. X    ( cd docs ; make helptree )
  158. X
  159. X# note that directory /usr/local/help must exist for the help tree
  160. X# to be created
  161. Xinstall: gnuplot help_system doc_tree man_install
  162. X    cp gnuplot $(DEST)
  163. X    strip $(DEST)
  164. X    docs/helptree -t /usr/local/help/gnuplot < docs/gnuplot.hlp
  165. X    cd help; make install
  166. X
  167. Xman_install: gnuplot.1
  168. X    cp gnuplot.1 $(MANDEST)
  169. X
  170. Xterm.o: term.c aed.trm bitgraph.trm hp26.trm hp75.trm hpljet.trm pc.trm \
  171. X    postscpt.trm qms.trm regis.trm selanar.trm tek.trm unixpc.trm \
  172. X    unixplot.trm v384.trm
  173. X    cc $(CFLAGS) $(TERMFLAGS) -c term.c
  174. X
  175. X
  176. X$(OBJS): plot.h
  177. X
  178. Xclean:
  179. X    rm -f *.o gnuplot
  180. X
  181. X    ( cd help ; make clean )
  182. X    ( cd docs ; make clean )
  183. X
  184. Xspotless:
  185. X    rm -f *.o gnuplot Makefile help/Makefile
  186. X
  187. X    ( cd help ; make clean -f makefile.unx )
  188. X    ( cd docs ; make clean )
  189. X
  190. X#
  191. X# if you have the Rich $alz shar package, you can use this make shar section.
  192. X#
  193. X
  194. Xshars:    spotless shar/gnuplot.shar.1 shar/gnuplot.shar.2 \
  195. X    shar/gnuplot.shar.3 shar/gnuplot.shar.4 shar/gnuplot.shar.5 \
  196. X    shar/gnuplot.shar.6 shar/gnuplot.shar.7
  197. X
  198. Xshar/gnuplot.shar.1: [1-9]* [A-Z]* [a-f]*
  199. X    shar -n1 -e7 [1-9]* [A-Z]* [a-f]* > shar/gnuplot.shar.1
  200. X
  201. Xshar/gnuplot.shar.2: [g-l]*
  202. X    shar -n2 -e7 [g-l]* > shar/gnuplot.shar.2
  203. X
  204. Xshar/gnuplot.shar.3: [m-o]* p[a-i]*
  205. X    shar -n3 -e7 [m-o]* p[a-i]* > shar/gnuplot.shar.3
  206. X
  207. Xshar/gnuplot.shar.4: p[j-z]* [q-t]*
  208. X    shar -n4 -e7 p[j-z]* [q-t]* > shar/gnuplot.shar.4
  209. X
  210. Xshar/gnuplot.shar.5: [u-z]*
  211. X    shar -n5 -e7 [u-z]* > shar/gnuplot.shar.5
  212. X
  213. Xshar/gnuplot.shar.6: docs/[A-Z]* docs/[a-g]*
  214. X    cd docs; make clean; cd ..
  215. X    shar -n6 -e7 docs docs/[A-Z]* docs/[a-g]* > shar/gnuplot.shar.6
  216. X
  217. Xshar/gnuplot.shar.7: docs/[h-z]* help/*
  218. X    shar -n7 -e7 docs/[h-z]* help help/* > shar/gnuplot.shar.7
  219. X
  220. END_OF_FILE
  221. if test 3933 -ne `wc -c <'makefile.3b1'`; then
  222.     echo shar: \"'makefile.3b1'\" unpacked with wrong size!
  223. fi
  224. # end of 'makefile.3b1'
  225. fi
  226. if test -f 'makefile.tc' -a "${1}" != "-c" ; then 
  227.   echo shar: Will not clobber existing file \"'makefile.tc'\"
  228. else
  229. echo shar: Extracting \"'makefile.tc'\" \(1127 characters\)
  230. sed "s/^X//" >'makefile.tc' <<'END_OF_FILE'
  231. X# make file for Turbo C
  232. X# Modified from MSC make by John Campbell and Bill Wilson
  233. X# The compile and link includes debug flags.  Take them out if you
  234. X# do not want them included
  235. X
  236. XOBJS =     command.obj eval.obj graphics.obj internal.obj misc.obj parse.obj plot.obj scanner.obj standard.obj term.obj util.obj version.obj 
  237. X
  238. Xgnuplot.exe: $(OBJS) 
  239. X tlink /m /s /v /l @link.otc
  240. X
  241. X# /AC means use compact model (small code, large data)
  242. XCFLAGS = -c -f -ml -M -y -v -I\tc\include -DMSDOS -DPC
  243. XTERMFLAGS = 
  244. X# -DHERCULES -DCGA
  245. X
  246. X# default rules
  247. X.c.obj:
  248. X    tcc $(CFLAGS) $*
  249. X
  250. Xcommand.obj: command.c plot.h
  251. X
  252. Xeval.obj: eval.c plot.h
  253. X
  254. Xgraphics.obj: graphics.c plot.h
  255. X
  256. Xinternal.obj: internal.c plot.h
  257. X
  258. Xmisc.obj: misc.c plot.h
  259. X
  260. Xparse.obj: parse.c plot.h
  261. X
  262. Xplot.obj: plot.c plot.h
  263. X
  264. Xscanner.obj: scanner.c plot.h
  265. X
  266. Xstandard.obj: standard.c plot.h
  267. X
  268. Xterm.obj: term.c plot.h \
  269. X    aed.trm bitgraph.trm hp26.trm hp75.trm hpljet.trm pc.trm \
  270. X    postscpt.trm qms.trm regis.trm selanar.trm tek.trm unixpc.trm \
  271. X    unixplot.trm v384.trm
  272. X    tcc $(CFLAGS) $(TERMFLAGS) term.c
  273. X    
  274. Xutil.obj: util.c plot.h
  275. X
  276. Xversion.obj: version.c
  277. X
  278. X
  279. X# use link.opt to avoid command-line overflow
  280. X
  281. END_OF_FILE
  282. if test 1127 -ne `wc -c <'makefile.tc'`; then
  283.     echo shar: \"'makefile.tc'\" unpacked with wrong size!
  284. fi
  285. # end of 'makefile.tc'
  286. fi
  287. if test -f 'makefile.unx' -a "${1}" != "-c" ; then 
  288.   echo shar: Will not clobber existing file \"'makefile.unx'\"
  289. else
  290. echo shar: Extracting \"'makefile.unx'\" \(3970 characters\)
  291. sed "s/^X//" >'makefile.unx' <<'END_OF_FILE'
  292. X# "make all" will compile all the necessary programs, gnuplot itself, the
  293. X# help system and helptree (to make the help tree out of the flat file.)
  294. X#
  295. X# "make install will install all the necessary pieces to run gnuplot
  296. X# successfully.  This includes creating the help tree in /usr/local/help.
  297. X
  298. X# If you do not wish the destinations of the executable and manual page to
  299. X# be at the default locations (see below), feel free to change them.
  300. X# The location of the help system and help tree also have default values.
  301. X# If you want them somewhere else or would like to test the whole system
  302. X# before you run "make install", you have to set environment variables so
  303. X# that gnuplot finds them.  See README.3B1 for details.
  304. X
  305. X# where to install executable on 'make install'
  306. XDEST=/usr/local/bin/gnuplot
  307. X# where to install man page on 'make man_install'
  308. XMANDEST=/usr/man/man1/gnuplot.1
  309. X
  310. X# -DFORK if you have vfork()
  311. X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
  312. X# -DNOCOPY if you don't have a memcpy() by any name
  313. X# -DGAMMA if you've got gamma(3)
  314. X# -O if you trust your compiler's optimizer
  315. XCFLAGS = -DVFORK -DBCOPY -DGAMMA #-gx #-O
  316. X
  317. X# -D<terminal> in TERMFLAGS iff you wish to support <terminal>
  318. X# -DAED         AED 512 and AED 767
  319. X# -DBITGRAPH    BBN BitGraph
  320. X# -DHP26        HP2623A and maybe others
  321. X# -DHP75        HP7580, and probably other HPs
  322. X# -DHPLJET      HP LaserJet laserprinter
  323. X# -DPOSTSCRIPT  Postscript
  324. X# -DQMS         QMS/QUIC laserprinter (Talaris 1200 and others)
  325. X# -DREGIS       ReGis graphics (vt125, vt220, vt240, Gigis...)
  326. X# -DSELANAR     Selanar
  327. X# -DTEK         Tektronix 4010, and probably others
  328. X# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
  329. X# -DUNIXPLOT    unixplot
  330. X# -DV384        Vectrix 384 and tandy color printer
  331. X
  332. XTERMFLAGS = -DAED -DBITGRAPH -DHP26 -DHP75 -DPOSTSCRIPT -DQMS -DREGIS -DSELANAR -DTEK -DUNIXPLOT -DV384
  333. X
  334. X
  335. XOBJS =     command.o eval.o graphics.o internal.o misc.o parse.o plot.o scanner.o\
  336. X    standard.o term.o util.o
  337. X
  338. X# -lplot if you have -DUNIXPLOT
  339. XLIBS = -lm -lplot
  340. X
  341. X# If you do not wish to compile the help system or make the help directory
  342. X# tree, feel free to comment out the appropriate lines that do it.
  343. X
  344. Xall:    gnuplot help_system doc_tree
  345. X
  346. Xgnuplot: $(OBJS) version.o
  347. X    cc $(OBJS) version.o $(LIBS) -o gnuplot
  348. X
  349. Xhelp_system:
  350. X    ( cd help ; make )
  351. X
  352. Xdoc_tree:
  353. X    ( cd docs ; make helptree )
  354. X
  355. X# note that directory /usr/local/help must exist for the help tree
  356. X# to be created
  357. Xinstall: gnuplot help_system doc_tree man_install
  358. X    cp gnuplot $(DEST)
  359. X    strip $(DEST)
  360. X    docs/helptree -t /usr/local/help/gnuplot < docs/gnuplot.hlp
  361. X    cd help; make install
  362. X
  363. Xman_install: gnuplot.1
  364. X    cp gnuplot.1 $(MANDEST)
  365. X
  366. Xterm.o: term.c aed.trm bitgraph.trm hp26.trm hp75.trm hpljet.trm pc.trm \
  367. X    postscpt.trm qms.trm regis.trm selanar.trm tek.trm unixpc.trm \
  368. X    unixplot.trm v384.trm
  369. X    cc $(CFLAGS) $(TERMFLAGS) -c term.c
  370. X
  371. X
  372. X$(OBJS): plot.h
  373. X
  374. Xclean:
  375. X    rm -f *.o gnuplot
  376. X
  377. X    ( cd help ; make clean )
  378. X    ( cd docs ; make clean )
  379. X
  380. Xspotless:
  381. X    rm -f *.o gnuplot Makefile help/Makefile
  382. X
  383. X    ( cd help ; make clean -f makefile.unx )
  384. X    ( cd docs ; make clean )
  385. X
  386. X#
  387. X# if you have the Rich $alz shar package, you can use this make shar section.
  388. X#
  389. X
  390. Xshars:    spotless shar/gnuplot.shar.1 shar/gnuplot.shar.2 \
  391. X    shar/gnuplot.shar.3 shar/gnuplot.shar.4 shar/gnuplot.shar.5 \
  392. X    shar/gnuplot.shar.6 shar/gnuplot.shar.7
  393. X
  394. Xshar/gnuplot.shar.1: [1-9]* [A-Z]* [a-f]*
  395. X    shar -n1 -e7 [1-9]* [A-Z]* [a-f]* > shar/gnuplot.shar.1
  396. X
  397. Xshar/gnuplot.shar.2: [g-l]*
  398. X    shar -n2 -e7 [g-l]* > shar/gnuplot.shar.2
  399. X
  400. Xshar/gnuplot.shar.3: [m-o]* p[a-i]*
  401. X    shar -n3 -e7 [m-o]* p[a-i]* > shar/gnuplot.shar.3
  402. X
  403. Xshar/gnuplot.shar.4: p[j-z]* [q-t]*
  404. X    shar -n4 -e7 p[j-z]* [q-t]* > shar/gnuplot.shar.4
  405. X
  406. Xshar/gnuplot.shar.5: [u-z]*
  407. X    shar -n5 -e7 [u-z]* > shar/gnuplot.shar.5
  408. X
  409. Xshar/gnuplot.shar.6: docs/[A-Z]* docs/[a-g]*
  410. X    cd docs; make clean; cd ..
  411. X    shar -n6 -e7 docs docs/[A-Z]* docs/[a-g]* > shar/gnuplot.shar.6
  412. X
  413. Xshar/gnuplot.shar.7: docs/[h-z]* help/*
  414. X    shar -n7 -e7 docs/[h-z]* help help/* > shar/gnuplot.shar.7
  415. X
  416. END_OF_FILE
  417. if test 3970 -ne `wc -c <'makefile.unx'`; then
  418.     echo shar: \"'makefile.unx'\" unpacked with wrong size!
  419. fi
  420. # end of 'makefile.unx'
  421. fi
  422. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  423.   echo shar: Will not clobber existing file \"'misc.c'\"
  424. else
  425. echo shar: Extracting \"'misc.c'\" \(6275 characters\)
  426. sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  427. X/*
  428. X *
  429. X *    G N U P L O T  --  misc.c
  430. X *
  431. X *  Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
  432. X *
  433. X *  You may use this code as you wish if credit is given and this message
  434. X *  is retained.
  435. X *
  436. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  437. X *  included in later releases.
  438. X *
  439. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  440. X */
  441. X
  442. X#include <stdio.h>
  443. X#include "plot.h"
  444. X#ifdef __TURBOC__
  445. X#include <graphics.h>
  446. X#endif
  447. X
  448. Xextern BOOLEAN autoscale;
  449. Xextern BOOLEAN polar;
  450. Xextern BOOLEAN log_x, log_y;
  451. Xextern FILE* outfile;
  452. Xextern char outstr[];
  453. Xextern int samples;
  454. Xextern int term;
  455. Xextern double zero;
  456. Xextern double roff, loff, toff, boff;
  457. X
  458. Xextern BOOLEAN screen_ok;
  459. X
  460. Xextern int c_token;
  461. Xextern struct at_type at;
  462. Xextern struct ft_entry ft[];
  463. Xextern struct udft_entry *first_udf;
  464. Xextern struct udvt_entry *first_udv;
  465. Xextern struct termentry term_tbl[];
  466. X
  467. Xchar *malloc();
  468. X
  469. Xstruct at_type *temp_at();
  470. X
  471. X
  472. X/*
  473. X * cp_free() releases any memory which was previously malloc()'d to hold
  474. X *   curve points.
  475. X */
  476. Xcp_free(cp)
  477. Xstruct curve_points *cp;
  478. X{
  479. X    if (cp) {
  480. X        cp_free(cp->next_cp);
  481. X        if (cp->title)
  482. X            free((char *)cp->title);
  483. X        free((char *)cp);
  484. X    }
  485. X}
  486. X
  487. X
  488. X
  489. Xsave_functions(fp)
  490. XFILE *fp;
  491. X{
  492. Xregister struct udft_entry *udf = first_udf;
  493. X    
  494. X    if (fp) {
  495. X        while (udf) {
  496. X            if (udf->definition)
  497. X                fprintf(fp,"%s\n",udf->definition);
  498. X            udf = udf->next_udf;
  499. X        }
  500. X        (void) fclose(fp);
  501. X    } else
  502. X        os_error("Cannot open save file",c_token);            
  503. X}
  504. X
  505. X
  506. Xsave_variables(fp)
  507. XFILE *fp;
  508. X{
  509. Xregister struct udvt_entry *udv = first_udv->next_udv;    /* skip pi */
  510. X
  511. X    if (fp) {
  512. X        while (udv) {
  513. X            if (!udv->udv_undef) {
  514. X                fprintf(fp,"%s = ",udv->udv_name);
  515. X                disp_value(fp,&(udv->udv_value));
  516. X                (void) putc('\n',fp);
  517. X            }
  518. X            udv = udv->next_udv;
  519. X        }
  520. X        (void) fclose(fp);
  521. X    } else
  522. X        os_error("Cannot open save file",c_token);            
  523. X}
  524. X
  525. X
  526. Xsave_all(fp)
  527. XFILE *fp;
  528. X{
  529. Xregister struct udft_entry *udf = first_udf;
  530. Xregister struct udvt_entry *udv = first_udv->next_udv;    /* skip pi */
  531. X
  532. X    if (fp) {
  533. X        while (udf) {
  534. X            if (udf->definition)
  535. X                fprintf(fp,"%s\n",udf->definition);
  536. X            udf = udf->next_udf;
  537. X        }
  538. X        while (udv) {
  539. X            if (!udv->udv_undef) {
  540. X                fprintf(fp,"%s = ",udv->udv_name);
  541. X                disp_value(fp,&(udv->udv_value));
  542. X                (void) putc('\n',fp);
  543. X            }
  544. X            udv = udv->next_udv;
  545. X        }
  546. X        (void) fclose(fp);
  547. X    } else
  548. X        os_error("Cannot open save file",c_token);            
  549. X}
  550. X
  551. X
  552. Xload_file(fp)
  553. XFILE *fp;
  554. X{
  555. Xregister int len;
  556. Xextern char input_line[];
  557. X
  558. X    if (fp) {
  559. X        while (fgets(input_line,MAX_LINE_LEN,fp)) {
  560. X            len = strlen(input_line) - 1;
  561. X            if (input_line[len] == '\n')
  562. X                input_line[len] = '\0';
  563. X
  564. X            screen_ok = FALSE;    /* make sure command line is
  565. X                       echoed on error */
  566. X            do_line();
  567. X        }
  568. X        (void) fclose(fp);
  569. X    } else
  570. X        os_error("Cannot open load file",c_token);
  571. X}
  572. X
  573. X
  574. Xshow_style(name,style)
  575. Xchar name[];
  576. Xenum PLOT_STYLE style;
  577. X{
  578. X    fprintf(stderr,"\t%s are plotted with ",name);
  579. X    switch (style) {
  580. X        case LINES: fprintf(stderr,"lines\n"); break;
  581. X        case POINTS: fprintf(stderr,"points\n"); break;
  582. X        case IMPULSES: fprintf(stderr,"impulses\n"); break;
  583. X    }
  584. X}
  585. X
  586. Xshow_range(name,min,max)
  587. Xchar name;
  588. Xdouble min,max;
  589. X{
  590. X    fprintf(stderr,"\t%crange is [%g : %g]\n",name,min,max);
  591. X}
  592. X
  593. Xshow_zero()
  594. X{
  595. X    fprintf(stderr,"\tzero is %g\n",zero);
  596. X}
  597. X
  598. Xshow_offsets()
  599. X{
  600. X    fprintf(stderr,"\toffsets are %g, %g, %g, %g\n",roff,loff,toff,boff);
  601. X}
  602. X
  603. Xshow_samples()
  604. X{
  605. X    fprintf(stderr,"\tsampling rate is %d\n",samples);
  606. X}
  607. X
  608. Xshow_output()
  609. X{
  610. X    fprintf(stderr,"\toutput is sent to %s\n",outstr);
  611. X}
  612. X
  613. Xshow_term()
  614. X{
  615. X    fprintf(stderr,"\tterminal type is %s\n",term_tbl[term].name);
  616. X}
  617. X
  618. Xshow_polar()
  619. X{
  620. X    if (polar)
  621. X        fprintf(stderr,"\tPolar coordinates are in effect\n");
  622. X    else
  623. X        fprintf(stderr,"\tRectangular coordinates are in effect\n");
  624. X}
  625. X
  626. Xshow_autoscale()
  627. X{
  628. X    fprintf(stderr,"\tautoscaling is %s\n",(autoscale)? "ON" : "OFF");
  629. X}
  630. X
  631. Xshow_logscale()
  632. X{
  633. X    if (log_x && log_y)
  634. X        fprintf(stderr,"\tlogscaling both x and y axes\n");
  635. X    else if (log_x)
  636. X        fprintf(stderr,"\tlogscaling x axis\n");
  637. X    else if (log_y)
  638. X        fprintf(stderr,"\tlogscaling y axis\n");
  639. X    else
  640. X        fprintf(stderr,"\tno logscaling\n");
  641. X}
  642. X
  643. Xshow_variables()
  644. X{
  645. Xregister struct udvt_entry *udv = first_udv;
  646. X
  647. X    fprintf(stderr,"\n\tVariables:\n");
  648. X    while (udv) {
  649. X        fprintf(stderr,"\t%-*s ",MAX_ID_LEN,udv->udv_name);
  650. X        if (udv->udv_undef)
  651. X            fputs("is undefined\n",stderr);
  652. X        else {
  653. X            fputs("= ",stderr);
  654. X            disp_value(stderr,&(udv->udv_value));
  655. X            (void) putc('\n',stderr);
  656. X        }
  657. X        udv = udv->next_udv;
  658. X    }
  659. X}
  660. X
  661. X
  662. Xshow_functions()
  663. X{
  664. Xregister struct udft_entry *udf = first_udf;
  665. X
  666. X    fprintf(stderr,"\n\tUser-Defined Functions:\n");
  667. X
  668. X    while (udf) {
  669. X        if (udf->definition)
  670. X            fprintf(stderr,"\t%s\n",udf->definition);
  671. X        else
  672. X            fprintf(stderr,"\t%s is undefined\n",udf->udf_name);
  673. X        udf = udf->next_udf;
  674. X    }
  675. X}
  676. X
  677. X
  678. Xshow_at()
  679. X{
  680. X    (void) putc('\n',stderr);
  681. X    disp_at(temp_at(),0);
  682. X}
  683. X
  684. X
  685. Xdisp_at(curr_at, level)
  686. Xstruct at_type *curr_at;
  687. Xint level;
  688. X{
  689. Xregister int i, j;
  690. Xregister union argument *arg;
  691. X
  692. X    for (i = 0; i < curr_at->a_count; i++) {
  693. X        (void) putc('\t',stderr);
  694. X        for (j = 0; j < level; j++)
  695. X            (void) putc(' ',stderr);    /* indent */
  696. X
  697. X            /* print name of instruction */
  698. X
  699. X        fputs(ft[(int)(curr_at->actions[i].index)].f_name,stderr);
  700. X        arg = &(curr_at->actions[i].arg);
  701. X
  702. X            /* now print optional argument */
  703. X
  704. X        switch(curr_at->actions[i].index) {
  705. X          case PUSH:    fprintf(stderr," %s\n", arg->udv_arg->udv_name);
  706. X                    break;
  707. X          case PUSHC:    (void) putc(' ',stderr);
  708. X                    disp_value(stderr,&(arg->v_arg));
  709. X                    (void) putc('\n',stderr);
  710. X                    break;
  711. X          case PUSHD:    fprintf(stderr," %s dummy\n",
  712. X                      arg->udf_arg->udf_name);
  713. X                    break;
  714. X          case CALL:    fprintf(stderr," %s", arg->udf_arg->udf_name);
  715. X                    if (arg->udf_arg->at) {
  716. X                        (void) putc('\n',stderr);
  717. X                        disp_at(arg->udf_arg->at,level+2); /* recurse! */
  718. X                    } else
  719. X                        fputs(" (undefined)\n",stderr);
  720. X                    break;
  721. X          case JUMP:
  722. X          case JUMPZ:
  723. X          case JUMPNZ:
  724. X          case JTERN:
  725. X                    fprintf(stderr," +%d\n",arg->j_arg);
  726. X                    break;
  727. X          default:
  728. X                    (void) putc('\n',stderr);
  729. X        }
  730. X    }
  731. X}
  732. X
  733. X
  734. Xshow_version()
  735. X{
  736. Xextern char version[];
  737. Xextern char date[];
  738. Xstatic char *authors[] = {"Thomas Williams","Colin Kelley"};
  739. Xint x;
  740. Xlong time();
  741. X
  742. X    x = time((long *)NULL) & 1;
  743. X    fprintf(stderr,"\n\t%s\n\t%sversion %s\n\tlast modified %s\n",
  744. X        PROGRAM, OS, version, date);
  745. X    fprintf(stderr,"\tCopyright (C) 1986, 1987  %s, %s\n\n",
  746. X        authors[x],authors[1-x]);
  747. X}
  748. END_OF_FILE
  749. if test 6275 -ne `wc -c <'misc.c'`; then
  750.     echo shar: \"'misc.c'\" unpacked with wrong size!
  751. fi
  752. # end of 'misc.c'
  753. fi
  754. if test -f 'parse.c' -a "${1}" != "-c" ; then 
  755.   echo shar: Will not clobber existing file \"'parse.c'\"
  756. else
  757. echo shar: Extracting \"'parse.c'\" \(7828 characters\)
  758. sed "s/^X//" >'parse.c' <<'END_OF_FILE'
  759. X/*
  760. X *
  761. X *    G N U P L O T  --  parse.c
  762. X *
  763. X *  Copyright (C) 1986, 1987  Colin Kelley, Thomas Williams
  764. X *
  765. X *  You may use this code as you wish if credit is given and this message
  766. X *  is retained.
  767. X *
  768. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  769. X *  included in later releases.
  770. X *
  771. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  772. X */
  773. X
  774. X#include <stdio.h>
  775. X#include <setjmp.h>
  776. X#include <signal.h>
  777. X#include <errno.h>
  778. X#include "plot.h"
  779. X
  780. Xextern BOOLEAN undefined;
  781. X
  782. X#ifndef vms
  783. Xextern int errno;
  784. X#endif
  785. X
  786. Xextern int num_tokens,c_token;
  787. Xextern struct lexical_unit token[];
  788. Xextern char c_dummy_var[];            /* name of current dummy variable */
  789. Xextern struct udft_entry *dummy_func;    /* pointer to dummy variable's func */
  790. X
  791. Xchar *malloc();
  792. X
  793. Xstruct value *pop(),*integer(),*complex();
  794. Xstruct at_type *temp_at(), *perm_at();
  795. Xstruct udft_entry *add_udf();
  796. Xstruct udvt_entry *add_udv();
  797. Xunion argument *add_action();
  798. X
  799. Xstruct at_type at;
  800. Xstatic jmp_buf fpe_env;
  801. X
  802. X#define dummy (struct value *) 0
  803. X#ifdef __TURBOC__
  804. Xvoid fpe(int xXx)
  805. X#else
  806. Xfpe()
  807. X#endif
  808. X{
  809. X#ifdef PC    /* thanks to lotto@wjh12.UUCP for telling us about this  */
  810. X    _fpreset();
  811. X#endif
  812. X    (void) signal(SIGFPE, fpe);
  813. X    undefined = TRUE;
  814. X    longjmp(fpe_env, TRUE);
  815. X}
  816. X
  817. X
  818. Xevaluate_at(at_ptr,val_ptr)
  819. Xstruct at_type *at_ptr;
  820. Xstruct value *val_ptr;
  821. X{
  822. X    undefined = FALSE;
  823. X    errno = 0;
  824. X    reset_stack();
  825. X    if (setjmp(fpe_env))
  826. X        return;                /* just bail out */
  827. X    (void) signal(SIGFPE, fpe);    /* catch core dumps on FPEs */
  828. X
  829. X    execute_at(at_ptr);
  830. X
  831. X    (void) signal(SIGFPE, SIG_DFL);
  832. X
  833. X    if (errno == EDOM || errno == ERANGE) {
  834. X        undefined = TRUE;
  835. X    } else {
  836. X        (void) pop(val_ptr);
  837. X        check_stack();
  838. X    }
  839. X}
  840. X
  841. X
  842. Xstruct value *
  843. Xconst_express(valptr)
  844. Xstruct value *valptr;
  845. X{
  846. Xregister int tkn = c_token;
  847. X    if (END_OF_COMMAND)
  848. X        int_error("constant expression required",c_token);
  849. X    evaluate_at(temp_at(),valptr);    /* run it and send answer back */
  850. X    if (undefined) {
  851. X        int_error("undefined value",tkn);
  852. X    }
  853. X    return(valptr);
  854. X}
  855. X
  856. X
  857. Xstruct at_type *
  858. Xtemp_at()    /* build a static action table and return its pointer */
  859. X{
  860. X    at.a_count = 0;        /* reset action table !!! */
  861. X    express();
  862. X    return(&at);
  863. X}
  864. X
  865. X
  866. X/* build an action table, put it in dynamic memory, and return its pointer */
  867. X
  868. Xstruct at_type *
  869. Xperm_at()
  870. X{
  871. Xregister struct at_type *at_ptr;
  872. Xregister unsigned int len;
  873. X
  874. X    (void) temp_at();
  875. X    len = sizeof(struct at_type) -
  876. X        (MAX_AT_LEN - at.a_count)*sizeof(struct at_entry);
  877. X    if (at_ptr = (struct at_type *) malloc(len))
  878. X        (void) memcpy(at_ptr,&at,len);
  879. X    return(at_ptr);
  880. X}
  881. X
  882. X
  883. X#ifdef NOCOPY
  884. X/*
  885. X * cheap and slow version of memcpy() in case you don't have one
  886. X */
  887. Xmemcpy(dest,src,len)
  888. Xchar *dest,*src;
  889. Xunsigned int len;
  890. X{
  891. X    while (len--)
  892. X        *dest++ = *src++;
  893. X}
  894. X#endif /* NOCOPY */
  895. X
  896. X
  897. Xexpress()  /* full expressions */
  898. X{
  899. X    xterm();
  900. X    xterms();
  901. X}
  902. X
  903. Xxterm()  /* ? : expressions */
  904. X{
  905. X    aterm();
  906. X    aterms();
  907. X}
  908. X
  909. X
  910. Xaterm()
  911. X{
  912. X    bterm();
  913. X    bterms();
  914. X}
  915. X
  916. X
  917. Xbterm()
  918. X{
  919. X    cterm();
  920. X    cterms();
  921. X}
  922. X
  923. X
  924. Xcterm()
  925. X{
  926. X    dterm();
  927. X    dterms();
  928. X}
  929. X
  930. X
  931. Xdterm()
  932. X{    
  933. X    eterm();
  934. X    eterms();
  935. X}
  936. X
  937. X
  938. Xeterm()
  939. X{
  940. X    fterm();
  941. X    fterms();
  942. X}
  943. X
  944. X
  945. Xfterm()
  946. X{
  947. X    gterm();
  948. X    gterms();
  949. X}
  950. X
  951. X
  952. Xgterm()
  953. X{
  954. X    hterm();
  955. X    hterms();
  956. X}
  957. X
  958. X
  959. Xhterm()
  960. X{
  961. X    unary(); /* - things */
  962. X    iterms(); /* * / % */
  963. X}
  964. X
  965. X
  966. Xfactor()
  967. X{
  968. Xregister int value;
  969. X
  970. X    if (equals(c_token,"(")) {
  971. X        c_token++;
  972. X        express();
  973. X        if (!equals(c_token,")"))
  974. X            int_error("')' expected",c_token);
  975. X        c_token++;
  976. X    }
  977. X    else if (isnumber(c_token)) {
  978. X        convert(&(add_action(PUSHC)->v_arg),c_token);
  979. X        c_token++;
  980. X    }
  981. X    else if (isletter(c_token)) {
  982. X        if ((c_token+1 < num_tokens)  && equals(c_token+1,"(")) {
  983. X            value = standard(c_token);
  984. X            if (value) {    /* it's a standard function */
  985. X                c_token += 2;
  986. X                express();
  987. X                if (!equals(c_token,")"))
  988. X                    int_error("')' expected",c_token);
  989. X                c_token++;
  990. X                (void) add_action(value);
  991. X            }
  992. X            else {
  993. X                value = c_token;
  994. X                c_token += 2;
  995. X                express();
  996. X                if (!equals(c_token,")"))
  997. X                    int_error("')' expected",c_token);
  998. X                c_token++;
  999. X                add_action(CALL)->udf_arg = add_udf(value);
  1000. X            }
  1001. X        }
  1002. X        else {
  1003. X            if (equals(c_token,c_dummy_var)) {
  1004. X                c_token++;
  1005. X                add_action(PUSHD)->udf_arg = dummy_func;
  1006. X            }
  1007. X            else {
  1008. X                add_action(PUSH)->udv_arg = add_udv(c_token);
  1009. X                c_token++;
  1010. X            }
  1011. X        }
  1012. X    } /* end if letter */
  1013. X    else
  1014. X        int_error("invalid expression ",c_token);
  1015. X
  1016. X    /* add action code for ! (factorial) operator */
  1017. X    while (equals(c_token,"!")) {
  1018. X        c_token++;
  1019. X        (void) add_action(FACTORIAL);
  1020. X    }
  1021. X    /* add action code for ** operator */
  1022. X    if (equals(c_token,"**")) {
  1023. X            c_token++;
  1024. X            unary();
  1025. X            (void) add_action(POWER);
  1026. X    }
  1027. X
  1028. X}
  1029. X
  1030. X
  1031. X
  1032. Xxterms()
  1033. X{  /* create action code for ? : expressions */
  1034. X
  1035. X    if (equals(c_token,"?")) {
  1036. X        register int savepc1, savepc2;
  1037. X        register union argument *argptr1,*argptr2;
  1038. X        c_token++;
  1039. X        savepc1 = at.a_count;
  1040. X        argptr1 = add_action(JTERN);
  1041. X        express();
  1042. X        if (!equals(c_token,":"))
  1043. X            int_error("expecting ':'",c_token);
  1044. X        c_token++;
  1045. X        savepc2 = at.a_count;
  1046. X        argptr2 = add_action(JUMP);
  1047. X        argptr1->j_arg = at.a_count - savepc1;
  1048. X        express();
  1049. X        argptr2->j_arg = at.a_count - savepc2;
  1050. X    }
  1051. X}
  1052. X
  1053. X
  1054. Xaterms()
  1055. X{  /* create action codes for || operator */
  1056. X
  1057. X    while (equals(c_token,"||")) {
  1058. X        register int savepc;
  1059. X        register union argument *argptr;
  1060. X        c_token++;
  1061. X        savepc = at.a_count;
  1062. X        argptr = add_action(JUMPNZ);    /* short-circuit if already TRUE */
  1063. X        aterm();
  1064. X        argptr->j_arg = at.a_count - savepc;/* offset for jump */
  1065. X        (void) add_action(BOOL);
  1066. X    }
  1067. X}
  1068. X
  1069. X
  1070. Xbterms()
  1071. X{ /* create action code for && operator */
  1072. X
  1073. X    while (equals(c_token,"&&")) {
  1074. X        register int savepc;
  1075. X        register union argument *argptr;
  1076. X        c_token++;
  1077. X        savepc = at.a_count;
  1078. X        argptr = add_action(JUMPZ);    /* short-circuit if already FALSE */
  1079. X        bterm();
  1080. X        argptr->j_arg = at.a_count - savepc;/* offset for jump */
  1081. X        (void) add_action(BOOL);
  1082. X    }
  1083. X}
  1084. X
  1085. X
  1086. Xcterms()
  1087. X{ /* create action code for | operator */
  1088. X
  1089. X    while (equals(c_token,"|")) {
  1090. X        c_token++;
  1091. X        cterm();
  1092. X        (void) add_action(BOR);
  1093. X    }
  1094. X}
  1095. X
  1096. X
  1097. Xdterms()
  1098. X{ /* create action code for ^ operator */
  1099. X
  1100. X    while (equals(c_token,"^")) {
  1101. X        c_token++;
  1102. X        dterm();
  1103. X        (void) add_action(XOR);
  1104. X    }
  1105. X}
  1106. X
  1107. X
  1108. Xeterms()
  1109. X{ /* create action code for & operator */
  1110. X
  1111. X    while (equals(c_token,"&")) {
  1112. X        c_token++;
  1113. X        eterm();
  1114. X        (void) add_action(BAND);
  1115. X    }
  1116. X}
  1117. X
  1118. X
  1119. Xfterms()
  1120. X{ /* create action codes for == and != operators */
  1121. X
  1122. X    while (TRUE) {
  1123. X        if (equals(c_token,"==")) {
  1124. X            c_token++;
  1125. X            fterm();
  1126. X            (void) add_action(EQ);
  1127. X        }
  1128. X        else if (equals(c_token,"!=")) {
  1129. X            c_token++;
  1130. X            fterm();
  1131. X            (void) add_action(NE);
  1132. X        }
  1133. X        else break;
  1134. X    }
  1135. X}
  1136. X
  1137. X
  1138. Xgterms()
  1139. X{ /* create action code for < > >= or <= operators */
  1140. X    
  1141. X    while (TRUE) {
  1142. X        /* I hate "else if" statements */
  1143. X        if (equals(c_token,">")) {
  1144. X            c_token++;
  1145. X            gterm();
  1146. X            (void) add_action(GT);
  1147. X        }
  1148. X        else if (equals(c_token,"<")) {
  1149. X            c_token++;
  1150. X            gterm();
  1151. X            (void) add_action(LT);
  1152. X        }        
  1153. X        else if (equals(c_token,">=")) {
  1154. X            c_token++;
  1155. X            gterm();
  1156. X            (void) add_action(GE);
  1157. X        }
  1158. X        else if (equals(c_token,"<=")) {
  1159. X            c_token++;
  1160. X            gterm();
  1161. X            (void) add_action(LE);
  1162. X        }
  1163. X        else break;
  1164. X    }
  1165. X
  1166. X}
  1167. X
  1168. X
  1169. X
  1170. Xhterms()
  1171. X{ /* create action codes for + and - operators */
  1172. X
  1173. X    while (TRUE) {
  1174. X            if (equals(c_token,"+")) {
  1175. X                c_token++;
  1176. X                hterm();
  1177. X                (void) add_action(PLUS);
  1178. X            }
  1179. X            else if (equals(c_token,"-")) {
  1180. X                c_token++;
  1181. X                hterm();
  1182. X                (void) add_action(MINUS);
  1183. X            }
  1184. X            else break;
  1185. X    }
  1186. X}
  1187. X
  1188. X
  1189. Xiterms()
  1190. X{ /* add action code for * / and % operators */
  1191. X
  1192. X    while (TRUE) {
  1193. X            if (equals(c_token,"*")) {
  1194. X                c_token++;
  1195. X                unary();
  1196. X                (void) add_action(MULT);
  1197. X            }
  1198. X            else if (equals(c_token,"/")) {
  1199. X                c_token++;
  1200. X                unary();
  1201. X                (void) add_action(DIV);
  1202. X            }
  1203. X            else if (equals(c_token,"%")) {
  1204. X                c_token++;
  1205. X                unary();
  1206. X                (void) add_action(MOD);
  1207. X            }
  1208. X            else break;
  1209. X    }
  1210. X}
  1211. X
  1212. X
  1213. Xunary()
  1214. X{ /* add code for unary operators */
  1215. X    if (equals(c_token,"!")) {
  1216. X        c_token++;
  1217. X        unary();
  1218. X        (void) add_action(LNOT);
  1219. X    }
  1220. X    else if (equals(c_token,"~")) {
  1221. X        c_token++;
  1222. X        unary();
  1223. X        (void) add_action(BNOT);
  1224. X    }
  1225. X    else if (equals(c_token,"-")) {
  1226. X        c_token++;
  1227. X        unary();
  1228. X        (void) add_action(UMINUS);
  1229. X    }
  1230. X    else
  1231. X        factor();
  1232. X}
  1233. END_OF_FILE
  1234. if test 7828 -ne `wc -c <'parse.c'`; then
  1235.     echo shar: \"'parse.c'\" unpacked with wrong size!
  1236. fi
  1237. # end of 'parse.c'
  1238. fi
  1239. if test -f 'pc.trm' -a "${1}" != "-c" ; then 
  1240.   echo shar: Will not clobber existing file \"'pc.trm'\"
  1241. else
  1242. echo shar: Extracting \"'pc.trm'\" \(15550 characters\)
  1243. sed "s/^X//" >'pc.trm' <<'END_OF_FILE'
  1244. X#ifdef __TURBOC__
  1245. X#include <graphics.h>
  1246. X#include <dos.h>
  1247. X#include <string.h>
  1248. X  int g_driver, g_mode, g_error;
  1249. X  char far *path;
  1250. X  char *pathp, path_s[128];
  1251. X
  1252. Xget_path()
  1253. X{
  1254. X   path=getenv("BGI");
  1255. X   if (path==NULL) {
  1256. X      strcpy(path_s,_argv[0]);
  1257. X      pathp=strrchr(path_s,'\\');
  1258. X      *pathp=0x00;
  1259. X      path=path_s;
  1260. X   }
  1261. X}
  1262. X
  1263. X#endif
  1264. X
  1265. X/* all of the Turbo C routines for the different graphics devices go here */
  1266. X
  1267. X#define EGALIB_XMAX 640
  1268. X#define EGALIB_YMAX 350
  1269. X
  1270. X#define EGALIB_XLAST (EGA_XMAX - 1)
  1271. X#define EGALIB_YLAST (EGA_YMAX - 1)
  1272. X
  1273. X#define EGALIB_VCHAR 14
  1274. X#define EGALIB_HCHAR 8
  1275. X#define EGALIB_VTIC 4
  1276. X#define EGALIB_HTIC 5
  1277. X
  1278. Xstatic int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  1279. Xstatic int ega256color[] = {1,8,2,3,4,5,9,14,12,15,13,10,11,7,6};
  1280. X
  1281. Xstatic int *egacolor;
  1282. X
  1283. Xstatic char near buf[80];    /* kludge since EGA.LIB is compiled SMALL */
  1284. X
  1285. Xstatic int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  1286. X
  1287. Xstatic int graphics_on = FALSE;
  1288. Xint startx, starty;
  1289. X
  1290. Xpause()                                /* press any key to continue... */
  1291. X{
  1292. X    while (kbhit())
  1293. X        (void) getch();                /* flush the keyboard buffer */
  1294. X    while (!kbhit())
  1295. X        ;
  1296. X}
  1297. X
  1298. X
  1299. XPC_lrput_text(row,str)
  1300. Xint row;
  1301. Xchar str[];
  1302. X{
  1303. X#ifdef __TURBOC__
  1304. X    gotoxy(78-strlen(str),24-row);
  1305. X    puts(str);
  1306. X#else
  1307. X    PC_curloc(24-row,78-strlen(str));
  1308. X    PC_puts(str);
  1309. X#endif
  1310. X}
  1311. X
  1312. XPC_ulput_text(row,str)
  1313. Xint row;
  1314. Xchar str[];
  1315. X{
  1316. X#ifdef __TURBOC__
  1317. X    gotoxy(2,row+1);
  1318. X    puts(str);
  1319. X#else
  1320. X    PC_curloc(row+1,2);
  1321. X    PC_puts(str);
  1322. X#endif
  1323. X}
  1324. X
  1325. XPC_text()
  1326. X{
  1327. X    if (graphics_on) {
  1328. X        graphics_on = FALSE;
  1329. X        pause();
  1330. X    }
  1331. X#ifdef __TURBOC__
  1332. X    closegraph();
  1333. X#else
  1334. X    Vmode(3);
  1335. X#endif
  1336. X}
  1337. X
  1338. XPC_reset()
  1339. X{
  1340. X#ifdef __TURBOC__
  1341. X    closegraph();
  1342. X#endif
  1343. X}
  1344. X
  1345. X
  1346. X#ifdef __TURBOC__ 
  1347. X
  1348. X#define VGA_XMAX 640
  1349. X#define VGA_YMAX 480
  1350. X
  1351. X#define VGA_XLAST (VGA_XMAX - 1)
  1352. X#define VGA_YLAST (VGA_YMAX - 1)
  1353. X
  1354. X#define VGA_VCHAR 14
  1355. X#define VGA_HCHAR 8
  1356. X#define VGA_VTIC 4
  1357. X#define VGA_HTIC 5
  1358. X
  1359. Xstatic int vga256color[] = {1,8,2,3,4,5,9,14,12,15,13,10,11,7,6};
  1360. X
  1361. Xstatic int *vgacolor;
  1362. X
  1363. XVGA_init()
  1364. X{
  1365. X    g_driver=VGA;
  1366. X    g_mode=2;
  1367. X        initgraph(&g_driver,&g_mode,path);
  1368. X        if(g_driver!=9){
  1369. X          term=0;
  1370. X          switch (g_driver){
  1371. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1372. X                     break;
  1373. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1374. X                     break;
  1375. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1376. X                     break;
  1377. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1378. X                             "graphics driver.");
  1379. X                     break;
  1380. X            }
  1381. X            
  1382. X/*          int_error("color EGA board not found",NO_CARET);*/
  1383. X        }
  1384. X        if(g_driver==VGA) vgacolor=vga256color;
  1385. X}
  1386. X
  1387. XVGA_graphics()
  1388. X{       g_driver=VGA;
  1389. X    g_mode=2;
  1390. X    graphics_on = TRUE;
  1391. X    initgraph(&g_driver,&g_mode,path);
  1392. X}
  1393. X
  1394. XVGA_linetype(linetype)
  1395. X{
  1396. X    if (linetype >= 13)
  1397. X        linetype %= 13;
  1398. X    setcolor(vgacolor[linetype+2]);
  1399. X}
  1400. X
  1401. XVGA_lrput_text(row,str)
  1402. Xint row;
  1403. Xchar str[];
  1404. X{
  1405. X    strcpy((char far *)buf,str);
  1406. X    outtextxy(630-(strlen(str)*8),450-row*16,buf);
  1407. X}
  1408. X
  1409. X#define VGA_reset EGALIB_reset
  1410. X#define VGA_text EGALIB_text
  1411. X#define VGA_move EGALIB_move
  1412. X#define VGA_vector EGALIB_vector
  1413. X#define VGA_ulput_text EGALIB_ulput_text
  1414. X
  1415. XVGAMONO_linetype(linetype)
  1416. X{
  1417. X    if (linetype >= 5)
  1418. X        linetype %= 5;
  1419. X    setlinestyle(4,pattern[linetype+2],1);
  1420. X}
  1421. X
  1422. X#define MCGA_XMAX 640
  1423. X#define MCGA_YMAX 480
  1424. X
  1425. X#define MCGA_XLAST (MCGA_XMAX - 1)
  1426. X#define MCGA_YLAST (MCGA_YMAX - 1)
  1427. X
  1428. X#define MCGA_VCHAR 14
  1429. X#define MCGA_HCHAR 8
  1430. X#define MCGA_VTIC 4
  1431. X#define MCGA_HTIC 5
  1432. X
  1433. Xstatic int *MCGAcolor;
  1434. X
  1435. XMCGA_init()
  1436. X{
  1437. X    g_driver=MCGA;
  1438. X    g_mode=5;
  1439. X        initgraph(&g_driver,&g_mode,path);
  1440. X        if(g_driver!=2){
  1441. X          term=0;
  1442. X          switch (g_driver){
  1443. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1444. X                     break;
  1445. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1446. X                     break;
  1447. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1448. X                     break;
  1449. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1450. X                             "graphics driver.");
  1451. X                     break;
  1452. X            }
  1453. X            
  1454. X        }
  1455. X}
  1456. X
  1457. XMCGA_graphics()
  1458. X{       g_driver=MCGA;
  1459. X    g_mode=5;
  1460. X    graphics_on = TRUE;
  1461. X    initgraph(&g_driver,&g_mode,path);
  1462. X}
  1463. X
  1464. X
  1465. XMCGA_lrput_text(row,str)
  1466. Xint row;
  1467. Xchar str[];
  1468. X{
  1469. X    strcpy((char far *)buf,str);
  1470. X    outtextxy(630-(strlen(str)*8),450-row*16,buf);
  1471. X}
  1472. X
  1473. X#define MCGA_reset EGALIB_reset
  1474. X#define MCGA_text EGALIB_text
  1475. X#define MCGA_move EGALIB_move
  1476. X#define MCGA_vector EGALIB_vector
  1477. X#define MCGA_ulput_text EGALIB_ulput_text
  1478. X
  1479. XMCGA_linetype(linetype)
  1480. X{
  1481. X    if (linetype >= 5)
  1482. X        linetype %= 5;
  1483. X    setlinestyle(4,pattern[linetype+2],1);
  1484. X}
  1485. X
  1486. X
  1487. XEGALIB_init()
  1488. X{
  1489. X    g_driver=EGA;
  1490. X    g_mode=1;
  1491. X        initgraph(&g_driver,&g_mode,path);
  1492. X        if(g_driver<3 || g_driver>4){
  1493. X          term=0;
  1494. X          switch (g_driver){
  1495. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1496. X                     break;
  1497. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1498. X                     break;
  1499. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1500. X                     break;
  1501. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1502. X                             "graphics driver.");
  1503. X                     break;
  1504. X            }
  1505. X            
  1506. X/*          int_error("color EGA board not found",NO_CARET);*/
  1507. X        }
  1508. X        if(g_driver==EGA) egacolor=ega256color;
  1509. X        if(g_driver==EGA64) egacolor=ega64color;
  1510. X}
  1511. X
  1512. XEGALIB_graphics()
  1513. X{
  1514. X    graphics_on = TRUE;
  1515. X    initgraph(&g_driver,&g_mode,path);
  1516. X}
  1517. X
  1518. XEGALIB_text()
  1519. X{
  1520. X    if (graphics_on) {
  1521. X        graphics_on = FALSE;
  1522. X        pause();
  1523. X    }
  1524. X    closegraph();
  1525. X}
  1526. X
  1527. XEGALIB_linetype(linetype)
  1528. X{
  1529. X    if (linetype >= 13)
  1530. X        linetype %= 13;
  1531. X    setcolor(egacolor[linetype+2]);
  1532. X}
  1533. X
  1534. XEGALIB_move(x,y)
  1535. X{
  1536. X        moveto(x,getmaxy()-y);
  1537. X}
  1538. X
  1539. X
  1540. XEGALIB_vector(x,y)
  1541. X{
  1542. X    lineto(x,getmaxy()-y);
  1543. X}
  1544. X
  1545. X
  1546. XEGALIB_lrput_text(row,str)
  1547. Xint row;
  1548. Xchar str[];
  1549. X{
  1550. X    strcpy((char far *)buf,str);
  1551. X    outtextxy(630-(strlen(str)*8),320-row*16,buf);
  1552. X}
  1553. X
  1554. XEGALIB_ulput_text(row,str)
  1555. Xint row;
  1556. Xchar str[];
  1557. X{
  1558. X    strcpy((char far *)buf,str);
  1559. X    outtextxy(10,row*16+16,buf);
  1560. X}
  1561. X
  1562. XEGALIB_reset()
  1563. X{
  1564. X      closegraph();
  1565. X}
  1566. X
  1567. X#define CGA_XMAX 640
  1568. X#define CGA_YMAX 200
  1569. X
  1570. X#define CGA_XLAST (CGA_XMAX - 1)
  1571. X#define CGA_YLAST (CGA_YMAX - 1)
  1572. X
  1573. X#define CGA_VCHAR 8
  1574. X#define CGA_HCHAR 8
  1575. X#define CGA_VTIC 2
  1576. X#define CGA_HTIC 3
  1577. X
  1578. XCGA_init()
  1579. X{
  1580. X    g_driver=CGA;
  1581. X    g_mode=4;
  1582. X    initgraph(&g_driver,&g_mode,path);
  1583. X          switch (g_driver){
  1584. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1585. X                     break;
  1586. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1587. X                     break;
  1588. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1589. X                     break;
  1590. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1591. X                             "graphics driver.");
  1592. X                     break;
  1593. X            }
  1594. X/*    PC_color(1);         monochrome */
  1595. X
  1596. X}
  1597. X
  1598. XCGA_graphics()
  1599. X{
  1600. X    graphics_on = TRUE;
  1601. X    g_driver=CGA;
  1602. X    g_mode=4;
  1603. X    initgraph(&g_driver,&g_mode,path);
  1604. X    /*    Vmode(6);*/
  1605. X}
  1606. X
  1607. X#define CGA_text PC_text
  1608. X
  1609. XCGA_linetype(linetype)
  1610. X{
  1611. X    if (linetype >= 5)
  1612. X        linetype %= 5;
  1613. X/*    PC_mask(pattern[linetype+2]); */
  1614. X    setlinestyle(4,pattern[linetype+2],1);
  1615. X}
  1616. X
  1617. XCGA_move(x,y)
  1618. X{
  1619. X    moveto(x,y);
  1620. X}
  1621. X
  1622. X
  1623. XCGA_vector(x,y)
  1624. X{
  1625. X    lineto(x,y);
  1626. X}
  1627. X
  1628. X#define CGA_lrput_text PC_lrput_text
  1629. X#define CGA_ulput_text PC_ulput_text
  1630. X
  1631. X
  1632. X#define CGA_reset PC_reset
  1633. X
  1634. X#define HERC_XMAX 720
  1635. X#define HERC_YMAX 348
  1636. X
  1637. X#define HERC_XLAST (HERC_XMAX - 1)
  1638. X#define HERC_YLAST (HERC_YMAX - 1)
  1639. X
  1640. X#define HERC_VCHAR 8
  1641. X#define HERC_HCHAR 8
  1642. X#define HERC_VTIC 4
  1643. X#define HERC_HTIC 4
  1644. X
  1645. XHERC_init()
  1646. X{
  1647. X    g_driver=HERCMONO;
  1648. X    g_mode=0;
  1649. X      initgraph(&g_driver,&g_mode,path);
  1650. X          switch (g_driver){
  1651. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1652. X                     break;
  1653. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1654. X                     break;
  1655. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1656. X                     break;
  1657. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1658. X                             "graphics driver.");
  1659. X                     break;
  1660. X            }
  1661. X}
  1662. X
  1663. XHERC_graphics()
  1664. X{
  1665. X    g_driver=HERCMONO;
  1666. X    g_mode=0;
  1667. X    initgraph(&g_driver,&g_mode,path);
  1668. X    graphics_on = TRUE;
  1669. X}
  1670. X
  1671. XHERC_text()
  1672. X{
  1673. X    if (graphics_on) {
  1674. X        graphics_on = FALSE;
  1675. X        pause();
  1676. X    }
  1677. X    closegraph();
  1678. X}
  1679. X
  1680. XHERC_linetype(linetype)
  1681. X{
  1682. X    if (linetype >= 5)
  1683. X        linetype %= 5;
  1684. X
  1685. X    setlinestyle(linetype,0,1);
  1686. X}
  1687. X
  1688. XHERC_move(x,y)
  1689. X{
  1690. X    if (x < 0)
  1691. X        x = 0;
  1692. X    else if (x > HERC_XLAST)
  1693. X        x = HERC_XLAST;
  1694. X
  1695. X    if (y < 0)
  1696. X        y = 0;
  1697. X    else if (y > HERC_YLAST)
  1698. X        y = HERC_YLAST;
  1699. X    moveto(x,y);
  1700. X}
  1701. X
  1702. XHERC_vector(x,y)
  1703. X{
  1704. X    if (x < 0)
  1705. X        x = 0;
  1706. X    else if (x > HERC_XLAST)
  1707. X        x = HERC_XLAST;
  1708. X    if (y < 0)
  1709. X        y = 0;
  1710. X    else if (y > HERC_YLAST)
  1711. X        y = HERC_YLAST;
  1712. X
  1713. X    lineto(x,y);
  1714. X}
  1715. X
  1716. X/*
  1717. X   Thanks to James Dugal (jpd@usl.edu) for patching these two HERC 
  1718. X   routines.  (We need to remove the OLD (probably bad) code someday.)
  1719. X*/
  1720. X
  1721. XHERC_lrput_text(row,str)
  1722. Xint row;
  1723. Xchar str[];
  1724. X{
  1725. X#ifdef OLDHERC
  1726. X    gotoxy(79-strlen(str),24-row);
  1727. X    puts(str);
  1728. X#else
  1729. X    strcpy((char far *)buf,str);
  1730. X    outtextxy(710-(strlen(str)*8),318-row*10,buf);
  1731. X#endif
  1732. X}
  1733. X
  1734. XHERC_ulput_text(row,str)
  1735. Xint row;
  1736. Xchar str[];
  1737. X{
  1738. X#ifdef OLDHERC
  1739. X    gotoxy(2,row+1);
  1740. X    puts(str);
  1741. X#else
  1742. X    strcpy((char far *)buf,str);
  1743. X    outtextxy(10,row*10+10,buf);
  1744. X#endif
  1745. X}
  1746. X
  1747. X#define HERC_reset PC_reset
  1748. X
  1749. X
  1750. X#else
  1751. X
  1752. Xpause()                                /* press any key to continue... */
  1753. X{
  1754. X    while (kbhit())
  1755. X        (void) getch();                /* flush the keyboard buffer */
  1756. X    while (!kbhit())
  1757. X        ;
  1758. X}
  1759. X
  1760. X
  1761. XPC_lrput_text(row,str)
  1762. Xint row;
  1763. Xchar str[];
  1764. X{
  1765. X    PC_curloc(24-row,78-strlen(str));
  1766. X    PC_puts(str);
  1767. X}
  1768. X
  1769. XPC_ulput_text(row,str)
  1770. Xint row;
  1771. Xchar str[];
  1772. X{
  1773. X    PC_curloc(row+1,2);
  1774. X    PC_puts(str);
  1775. X}
  1776. X
  1777. XPC_text()
  1778. X{
  1779. X    if (graphics_on) {
  1780. X        graphics_on = FALSE;
  1781. X        pause();
  1782. X    }
  1783. X    Vmode(3);
  1784. X}
  1785. X
  1786. XPC_reset()
  1787. X{
  1788. X}
  1789. X#define CGA_XMAX 640
  1790. X#define CGA_YMAX 200
  1791. X
  1792. X#define CGA_XLAST (CGA_XMAX - 1)
  1793. X#define CGA_YLAST (CGA_YMAX - 1)
  1794. X
  1795. X#define CGA_VCHAR 8
  1796. X#define CGA_HCHAR 8
  1797. X#define CGA_VTIC 2
  1798. X#define CGA_HTIC 3
  1799. X
  1800. XCGA_init()
  1801. X{
  1802. X    PC_color(1);        /* monochrome */
  1803. X}
  1804. X
  1805. XCGA_graphics()
  1806. X{
  1807. X    graphics_on = TRUE;
  1808. X    Vmode(6);
  1809. X}
  1810. X
  1811. X#define CGA_text PC_text
  1812. X
  1813. XCGA_linetype(linetype)
  1814. X{
  1815. X    if (linetype >= 5)
  1816. X        linetype %= 5;
  1817. X    PC_mask(pattern[linetype+2]);
  1818. X}
  1819. X
  1820. XCGA_move(x,y)
  1821. X{
  1822. X    startx = x;
  1823. X    starty = y;
  1824. X}
  1825. X
  1826. X
  1827. XCGA_vector(x,y)
  1828. X{
  1829. X    PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
  1830. X    startx = x;
  1831. X    starty = y;
  1832. X}
  1833. X
  1834. X#define CGA_lrput_text PC_lrput_text
  1835. X#define CGA_ulput_text PC_ulput_text
  1836. X
  1837. X
  1838. X#define CGA_reset PC_reset
  1839. X
  1840. X
  1841. X#define EGA_XMAX 640
  1842. X#define EGA_YMAX 350
  1843. X
  1844. X#define EGA_XLAST (EGA_XMAX - 1)
  1845. X#define EGA_YLAST (EGA_YMAX - 1)
  1846. X
  1847. X#define EGA_VCHAR 14
  1848. X#define EGA_HCHAR 8
  1849. X#define EGA_VTIC 5
  1850. X#define EGA_HTIC 5
  1851. X
  1852. Xstatic int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  1853. Xstatic int ega256color[] = {1,8,2,3,4,5,9,14,12,15,13,10,11,7,6};
  1854. X
  1855. Xstatic int *egacolor;
  1856. X
  1857. X
  1858. XEGA_init()
  1859. X{
  1860. X    PC_mask(0xffff);
  1861. X    egacolor = ega256color;        /* should be smarter */
  1862. X}
  1863. X
  1864. XEGA_graphics()
  1865. X{
  1866. X    graphics_on = TRUE;
  1867. X    Vmode(16);
  1868. X}
  1869. X
  1870. X#define EGA_text PC_text
  1871. X
  1872. XEGA_linetype(linetype)
  1873. X{
  1874. X    if (linetype >= 13)
  1875. X        linetype %= 13;
  1876. X    PC_color(egacolor[linetype+2]);
  1877. X}
  1878. X
  1879. XEGA_move(x,y)
  1880. X{
  1881. X    startx = x;
  1882. X    starty = y;
  1883. X}
  1884. X
  1885. XEGA_vector(x,y)
  1886. X{
  1887. X    PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
  1888. X    startx = x;
  1889. X    starty = y;
  1890. X}
  1891. X
  1892. X#define EGA_lrput_text PC_lrput_text
  1893. X#define EGA_ulput_text PC_ulput_text
  1894. X
  1895. X
  1896. X#define EGA_reset PC_reset
  1897. X
  1898. X
  1899. X
  1900. X#ifdef EGALIB
  1901. X
  1902. X#define EGALIB_XMAX 640
  1903. X#define EGALIB_YMAX 350
  1904. X
  1905. X#define EGALIB_XLAST (EGA_XMAX - 1)
  1906. X#define EGALIB_YLAST (EGA_YMAX - 1)
  1907. X
  1908. X#define EGALIB_VCHAR 14
  1909. X#define EGALIB_HCHAR 8
  1910. X#define EGALIB_VTIC 4
  1911. X#define EGALIB_HTIC 5
  1912. X
  1913. X#include "mcega.h"
  1914. X
  1915. XEGALIB_init()
  1916. X{
  1917. X    GPPARMS();
  1918. X    if (GDTYPE != 5) {
  1919. X        term = 0;
  1920. X        int_error("color EGA board not found",NO_CARET);
  1921. X    }
  1922. X    egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
  1923. X}
  1924. X
  1925. XEGALIB_graphics()
  1926. X{
  1927. X    graphics_on = TRUE;
  1928. X    GPINIT();
  1929. X}
  1930. X
  1931. XEGALIB_text()
  1932. X{
  1933. X    if (graphics_on) {
  1934. X        graphics_on = FALSE;
  1935. X        pause();
  1936. X    }
  1937. X    GPTERM();
  1938. X}
  1939. X
  1940. XEGALIB_linetype(linetype)
  1941. X{
  1942. X    if (linetype >= 13)
  1943. X        linetype %= 13;
  1944. X    GPCOLOR(egacolor[linetype+2]);
  1945. X}
  1946. X
  1947. XEGALIB_move(x,y)
  1948. X{
  1949. X    GPMOVE(x,GDMAXROW-y);
  1950. X}
  1951. X
  1952. X
  1953. XEGALIB_vector(x,y)
  1954. X{
  1955. X    GPLINE(x,GDMAXROW-y);
  1956. X}
  1957. X
  1958. X
  1959. XEGALIB_lrput_text(row,str)
  1960. Xint row;
  1961. Xchar str[];
  1962. X{
  1963. X    strcpy((char far *)buf,str);
  1964. X    GotoXY(78-strlen(str),24-row);
  1965. X    gprintf(buf);
  1966. X}
  1967. X
  1968. XEGALIB_ulput_text(row,str)
  1969. Xint row;
  1970. Xchar str[];
  1971. X{
  1972. X    strcpy((char far *)buf,str);
  1973. X    GotoXY(2,row+1);
  1974. X    gprintf(buf);
  1975. X}
  1976. X
  1977. X#define EGALIB_reset PC_reset
  1978. X
  1979. X#endif /* EGALIB */
  1980. X
  1981. X
  1982. X#ifdef HERCULES
  1983. X
  1984. X#define HERC_XMAX 720
  1985. X#define HERC_YMAX 348
  1986. X
  1987. X#define HERC_XLAST (HERC_XMAX - 1)
  1988. X#define HERC_YLAST (HERC_YMAX - 1)
  1989. X
  1990. X#define HERC_VCHAR 8
  1991. X#define HERC_HCHAR 8
  1992. X#define HERC_VTIC 4
  1993. X#define HERC_HTIC 4
  1994. X
  1995. X
  1996. XHERC_init()
  1997. X{
  1998. X}
  1999. X
  2000. XHERC_graphics()
  2001. X{
  2002. X    HVmode(1);
  2003. X    graphics_on = TRUE;
  2004. X}
  2005. X
  2006. XHERC_text()
  2007. X{
  2008. X    if (graphics_on) {
  2009. X        graphics_on = FALSE;
  2010. X        pause();
  2011. X    }
  2012. X    HVmode(0);
  2013. X}
  2014. X
  2015. XHERC_linetype(linetype)
  2016. X{
  2017. X    if (linetype >= 5)
  2018. X        linetype %= 5;
  2019. X    H_mask(pattern[linetype+2]);
  2020. X}
  2021. X
  2022. XHERC_move(x,y)
  2023. X{
  2024. X    if (x < 0)
  2025. X        startx = 0;
  2026. X    else if (x > HERC_XLAST)
  2027. X        startx = HERC_XLAST;
  2028. X    else
  2029. X        startx = x;
  2030. X
  2031. X    if (y < 0)
  2032. X        starty = 0;
  2033. X    else if (y > HERC_YLAST)
  2034. X        starty = HERC_YLAST;
  2035. X    else
  2036. X        starty = y;
  2037. X}
  2038. X
  2039. XHERC_vector(x,y)
  2040. X{
  2041. X    if (x < 0)
  2042. X        x = 0;
  2043. X    else if (x > HERC_XLAST)
  2044. X        x = HERC_XLAST;
  2045. X    if (y < 0)
  2046. X        y = 0;
  2047. X    else if (y > HERC_YLAST)
  2048. X        y = HERC_YLAST;
  2049. X
  2050. X    H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
  2051. X    startx = x;
  2052. X    starty = y;
  2053. X}
  2054. X
  2055. XHERC_lrput_text(row,str)
  2056. Xint row;
  2057. Xchar str[];
  2058. X{
  2059. X    H_puts(str, 41-row, 87-strlen(str));
  2060. X}
  2061. X
  2062. XHERC_ulput_text(row,str)
  2063. Xint row;
  2064. Xchar str[];
  2065. X{
  2066. X    H_puts(str, row+1, 2);
  2067. X}
  2068. X
  2069. X#define HERC_reset PC_reset
  2070. X
  2071. X#endif /* HERCULES */
  2072. X
  2073. X
  2074. X/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  2075. X   ATT 6300 driver */ 
  2076. X
  2077. X
  2078. X#ifdef ATT6300
  2079. X
  2080. X#define ATT_XMAX 640
  2081. X#define ATT_YMAX 400
  2082. X
  2083. X#define ATT_XLAST (ATT_XMAX - 1)
  2084. X#define ATT_YLAST (ATT_YMAX - 1)
  2085. X
  2086. X#define ATT_VCHAR 8
  2087. X#define ATT_HCHAR 8
  2088. X#define ATT_VTIC 3
  2089. X#define ATT_HTIC 3
  2090. X
  2091. X#define ATT_init CGA_init
  2092. X
  2093. XATT_graphics()
  2094. X{
  2095. X    graphics_on = TRUE;
  2096. X    Vmode(0x40);        /* 40H is the magic number for the AT&T driver */
  2097. X}
  2098. X
  2099. X#define ATT_text CGA_text
  2100. X
  2101. X#define ATT_linetype CGA_linetype
  2102. X
  2103. X#define ATT_move CGA_move
  2104. X
  2105. XATT_vector(x,y)
  2106. X{
  2107. X    PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
  2108. X    startx = x;
  2109. X    starty = y;
  2110. X}
  2111. X
  2112. X#define ATT_lrput_text PC_lrput_text
  2113. X#define ATT_ulput_text PC_ulput_text
  2114. X
  2115. X
  2116. X#define ATT_reset CGA_reset
  2117. X
  2118. X#endif  /* ATT6300 */
  2119. X
  2120. X
  2121. X#ifdef CORONA
  2122. X
  2123. X#define COR_XMAX 640
  2124. X#define COR_YMAX 325
  2125. X
  2126. X#define COR_XLAST (COR_XMAX - 1)
  2127. X#define COR_YLAST (COR_YMAX - 1)
  2128. X
  2129. X#define COR_VCHAR 13
  2130. X#define COR_HCHAR 8
  2131. X#define COR_VTIC 4
  2132. X#define COR_HTIC 4
  2133. X
  2134. X
  2135. Xstatic int corscreen;        /* screen number, 0 - 7 */
  2136. X
  2137. XCOR_init()
  2138. X{
  2139. Xregister char *p;
  2140. X    if (!(p = getenv("CORSCREEN")))
  2141. X        int_error("must run CORPLOT for Corona graphics",NO_CARET);
  2142. X    corscreen = *p - '0';
  2143. X}
  2144. X
  2145. XCOR_graphics()
  2146. X{
  2147. X    graphics_on = TRUE;
  2148. X    Vmode(3);                /* clear text screen */
  2149. X    grinit(corscreen);
  2150. X    grandtx();
  2151. X}
  2152. X
  2153. XCOR_text()
  2154. X{
  2155. X    if (graphics_on) {
  2156. X        graphics_on = FALSE;
  2157. X        pause();
  2158. X    }
  2159. X    grreset();
  2160. X    txonly();
  2161. X    Vmode(3);
  2162. X}
  2163. X
  2164. XCOR_linetype(linetype)
  2165. X{
  2166. X    if (linetype >= 5)
  2167. X        linetype %= 5;
  2168. X    Cor_mask(pattern[linetype+2]);
  2169. X}
  2170. X
  2171. XCOR_move(x,y)
  2172. X{
  2173. X    if (x < 0)
  2174. X        startx = 0;
  2175. X    else if (x > COR_XLAST)
  2176. X        startx = COR_XLAST;
  2177. X    else
  2178. X        startx = x;
  2179. X
  2180. X    if (y < 0)
  2181. X        starty = 0;
  2182. X    else if (y > COR_YLAST)
  2183. X        starty = COR_YLAST;
  2184. X    else
  2185. X        starty = y;
  2186. X}
  2187. X
  2188. XCOR_vector(x,y)
  2189. X{
  2190. X    if (x < 0)
  2191. X        x = 0;
  2192. X    else if (x > COR_XLAST)
  2193. X        x = COR_XLAST;
  2194. X    if (y < 0)
  2195. X        y = 0;
  2196. X    else if (y > COR_YLAST)
  2197. X        y = COR_YLAST;
  2198. X
  2199. X    Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
  2200. X    startx = x;
  2201. X    starty = y;
  2202. X}
  2203. X
  2204. X#define COR_lrput_text PC_lrput_text
  2205. X#define COR_ulput_text PC_ulput_text
  2206. X
  2207. X#define COR_reset PC_reset
  2208. X
  2209. X#endif /* CORONA */
  2210. X
  2211. X#endif /* __TURBOC__ */
  2212. X
  2213. END_OF_FILE
  2214. if test 15550 -ne `wc -c <'pc.trm'`; then
  2215.     echo shar: \"'pc.trm'\" unpacked with wrong size!
  2216. fi
  2217. # end of 'pc.trm'
  2218. fi
  2219. if test -f 'pcgraph.asm' -a "${1}" != "-c" ; then 
  2220.   echo shar: Will not clobber existing file \"'pcgraph.asm'\"
  2221. else
  2222. echo shar: Extracting \"'pcgraph.asm'\" \(3165 characters\)
  2223. sed "s/^X//" >'pcgraph.asm' <<'END_OF_FILE'
  2224. XTITLE    PC graphics module
  2225. X;    Colin Kelley
  2226. X;    December 22, 1986
  2227. X;    modified January 1987 to use LINEPROC.MAC
  2228. X
  2229. Xinclude header.mac
  2230. X
  2231. Xif1
  2232. Xinclude lineproc.mac
  2233. Xendif
  2234. X
  2235. X
  2236. X_text    segment
  2237. X
  2238. X    public _PC_line, _PC_color, _PC_mask, _PC_curloc, _PC_puts, _Vmode
  2239. X    public _save_stack, _ss_interrupt
  2240. X    extrn _interrupt:near
  2241. X
  2242. Xpcpixel proc near
  2243. X    ror word ptr linemask,1
  2244. X    jc cont
  2245. X    ret
  2246. Xcont:
  2247. X    push ax
  2248. X    push bx
  2249. X    push cx
  2250. X    push dx
  2251. X    push bp
  2252. X    mov cx,ax        ; x
  2253. X    mov dx,bx        ; y
  2254. X    mov ah,0ch        ; ah = write pixel
  2255. X    mov al,byte ptr color
  2256. X
  2257. X    mov bh, 0        ; page 0
  2258. X    int 10h
  2259. X    pop bp
  2260. X    pop dx
  2261. X    pop cx
  2262. X    pop bx
  2263. X    pop ax
  2264. X    ret
  2265. Xpcpixel endp
  2266. X
  2267. Xlineproc _PC_line, pcpixel
  2268. X
  2269. X_PC_color proc near
  2270. X    push bp
  2271. X    mov bp,sp
  2272. X    mov al,[bp+X]            ; color
  2273. X    mov byte ptr color,al
  2274. X    pop bp
  2275. X    ret
  2276. X_PC_color endp
  2277. X
  2278. X_PC_mask proc near
  2279. X    push bp
  2280. X    mov bp,sp
  2281. X    mov ax,[bp+X]            ; mask
  2282. X    mov word ptr linemask,ax
  2283. X    pop bp
  2284. X    ret
  2285. X_PC_mask endp
  2286. X
  2287. X_Vmode    proc near
  2288. X    push bp
  2289. X    mov bp,sp
  2290. X    push si
  2291. X    push di
  2292. X    mov ax,[bp+X]
  2293. X    int 10h
  2294. X    pop di
  2295. X    pop si
  2296. X    pop bp
  2297. X    ret
  2298. X_Vmode    endp
  2299. X
  2300. X_PC_curloc proc near
  2301. X    push bp
  2302. X    mov bp,sp
  2303. X    mov dh, byte ptr [bp+X] ; row number
  2304. X    mov dl, byte ptr [bp+X+2] ; col number
  2305. X    mov bh, 0
  2306. X    mov ah, 2
  2307. X    int 10h
  2308. X    pop bp
  2309. X    ret
  2310. X_PC_curloc endp
  2311. X
  2312. X;
  2313. X; thanks to watale!broehl for finding a bug here--I wasn't pushing BP
  2314. X;   and reloading AH before INT 10H, which is necessary on genuine IBM
  2315. X;   boards...
  2316. X;
  2317. X_PC_puts proc near
  2318. X    push bp
  2319. X    mov bp,sp
  2320. X    push si
  2321. X    mov bl,byte ptr color
  2322. X    mov si,[bp+X]        ; offset
  2323. X
  2324. Xifdef LARGE_DATA
  2325. X    mov es,[bp+X+2]        ; segment if large or compact data model
  2326. Xendif
  2327. X
  2328. Xputs2:
  2329. X
  2330. Xifdef LARGE_DATA
  2331. X    mov al,es:[si]
  2332. Xelse
  2333. X    mov al,[si]
  2334. Xendif
  2335. X    or al,al
  2336. X    jz puts3
  2337. X    mov ah,0eh        ; write TTY char
  2338. X    int 10h
  2339. X    inc si
  2340. X    jmp short puts2
  2341. Xputs3:    pop si
  2342. X    pop bp
  2343. X    ret
  2344. X_PC_puts endp
  2345. X
  2346. X
  2347. X; int kbhit();
  2348. X;   for those without MSC 4.0
  2349. X; Use BIOS interrupt 16h to determine if a key is waiting in the buffer.
  2350. X; Return nonzero if so.
  2351. X;
  2352. X
  2353. Xbeginproc _kbhit
  2354. X    mov ah, 1        ; function code 1 is keyboard test
  2355. X    int 16h            ; keyboard functions
  2356. X    jnz kbfin        ; Exit if char available
  2357. X    xor ax, ax        ; No char:  return zero.
  2358. Xkbfin:    ret
  2359. X_kbhit    endp
  2360. X
  2361. X
  2362. X; _save_stack and _ss_interrupt are needed due to a bug in the MSC 4.0
  2363. X; code when run under MS-DOS 3.x.  Starting with 3.0, MS-DOS automatically
  2364. X; switches to an internal stack during system calls.  This leaves SS:SP
  2365. X; pointing at MS-DOS's stack when the ^C interrupt (INT 23H) is triggered.
  2366. X; MSC should restore its own stack before calling the user signal() routine,
  2367. X; but it doesn't.
  2368. X;
  2369. X; Presumably this code will be unnecessary in later releases of the compiler.
  2370. X;
  2371. X
  2372. X; _save_stack saves the current SS:SP to be loaded later by _ss_interrupt.
  2373. X;
  2374. X
  2375. Xbeginproc _save_stack
  2376. X    mov ax,ss
  2377. X    mov cs:save_ss,ax
  2378. X    mov ax,sp
  2379. X    mov cs:save_sp,ax
  2380. X    ret
  2381. X_save_stack endp
  2382. X
  2383. X
  2384. X; _ss_interrupt is called on ^C (INT 23H).  It restores SS:SP as saved in
  2385. X; _save_stack and then jumps to the C routine interrupt().
  2386. X;
  2387. Xbeginproc _ss_interrupt
  2388. X    cli            ; no interrupts while the stack is changed!
  2389. X    mov ax,-1        ; self-modifying code again
  2390. Xsave_ss    equ this word - 2
  2391. X    mov ss,ax
  2392. X    mov sp,-1        ; here too
  2393. Xsave_sp equ this word - 2
  2394. X    sti
  2395. X    jmp _interrupt        ; now it's safe to call the real routine
  2396. X_ss_interrupt endp
  2397. X
  2398. X
  2399. X_text    ends
  2400. X
  2401. X
  2402. Xconst    segment
  2403. Xlinemask dw -1
  2404. Xcolor    db 1
  2405. Xconst    ends
  2406. X
  2407. X    end
  2408. END_OF_FILE
  2409. if test 3165 -ne `wc -c <'pcgraph.asm'`; then
  2410.     echo shar: \"'pcgraph.asm'\" unpacked with wrong size!
  2411. fi
  2412. # end of 'pcgraph.asm'
  2413. fi
  2414. echo shar: End of archive 3 \(of 7\).
  2415. cp /dev/null ark3isdone
  2416. MISSING=""
  2417. for I in 1 2 3 4 5 6 7 ; do
  2418.     if test ! -f ark${I}isdone ; then
  2419.     MISSING="${MISSING} ${I}"
  2420.     fi
  2421. done
  2422. if test "${MISSING}" = "" ; then
  2423.     echo You have unpacked all 7 archives.
  2424.     rm -f ark[1-9]isdone
  2425. else
  2426.     echo You still need to unpack the following archives:
  2427.     echo "        " ${MISSING}
  2428. fi
  2429. ##  End of shell archive.
  2430. exit 0
  2431.